import java.util.Scanner;
//学号问题
public class code1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        long[] arr = new long[(int) n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextLong();
        }
        for (int i = 0; i < m; i++) {
            System.out.println(arr[(int) (sc.nextLong()-1)]);
        }
    }
}
